package com.tentact.servlets;

import com.tentact.service.DeptService;
import com.tentact.vo.Department;


import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "updateDeptServlet", value = "/updateDeptServlet")
public class updateDeptServlet extends HttpServlet {
    DeptService service =new DeptService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("进入修改servlet");
        System.out.println(request.getParameter("departmentid"));
        System.out.println(request.getParameter("newname"));

        int departmentid =Integer.parseInt(request.getParameter("departmentid"));
        String departmentname =request.getParameter("newname");

        System.out.println(departmentid);
        System.out.println(departmentname);

        Department department =new Department(departmentid,departmentname,"");

        if (service.updateDept(department)!=1){
            System.out.println("修改失败");
        }else {
            request.getRequestDispatcher("selectDeptServlet").forward(request,response);
        }





    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
